// 1. 引入reqeust
import request from '@/utils/request'
import type { AttrInfoModel, AttrListModel } from './interface/attrModel'
import type { CategoryIdModel } from './interface/categoryModel'


enum Api {
  // 获取属性列表
  getAttrListApi = '/admin/product/attrInfoList',
  // 删除某个属性
  deleteAttrApi = '/admin/product/deleteAttr',
  // 添加或更新平台属性
  saveOrUpdateAttrApi='/admin/product/saveAttrInfo'
}

export const reqGetAttrListData = ({category1Id,category2Id,category3Id }:CategoryIdModel) => {
  return request.get<any,AttrListModel>(Api.getAttrListApi + `/${category1Id}/${category2Id}/${category3Id}`)
}

export const reqDeleteAttr = (attrId:number) => {
  return request.delete<any,null>(Api.deleteAttrApi+`/${attrId}`)
}
//  3. 添加或更新属性
export const reqSaveOrUpdateAttrInfo = (attrInfo:AttrInfoModel) => {
  return request.post<any,null>(Api.saveOrUpdateAttrApi,attrInfo)
}
